home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / DESK / CORE / Desk / h_doc / WAssert < prev    next >
Text File  |  1996-05-21  |  2KB  |  68 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    WAssert.h
  12.     Author:  Copyright © 1993, 1994 Mark H. Wilkinson
  13.     Version: 1.01 (19 Jul 1994)
  14.     Purpose: Wimp version of ANSI assert() system, based on Desk_RISCOS_Lib
  15.              version presented in Archive magazine 6.12.53 by Remo Biagioni.
  16. */
  17.  
  18. /*  NOTES
  19.  *  Assertions are used for debugging programs. They should be placed liberally
  20.  *  throughout your code to check that certain conditions are met during
  21.  *  development, and then the program re-compiled without them for final
  22.  *  release.
  23.  *
  24.  *  e.g. if you have a function that expects a parameter which must be positive
  25.  *  then it should include a line like:
  26.  *    assert(parameter >= 0);
  27.  *
  28.  *  If 'parameter' is not >= 0 then a wimp error box will report the fact,
  29.  *  indicating where in your source the assertion failed.
  30.  *
  31.  *  To use assertions you must compile your code with _DEBUG defined
  32.  *  (i.e. run the compiler with the extra switch -Desk_D_DEBUG)
  33.  *
  34.  *  To build a release version of your program without the assertions in it
  35.  *  (which will reduce the size of the program and increase execution speed)
  36.  *  simply compile it ensuring that _DEBUG is not defined.
  37.  */
  38.  
  39. #ifdef __cplusplus
  40.     extern "C" {
  41. #endif
  42.  
  43. #ifndef __Desk_WAssert_h
  44. #define __Desk_WAssert_h
  45.  
  46.  
  47. extern void Desk_WAssert__wassert(char *);
  48.  
  49.  
  50. #else
  51. #  undef assert
  52. #endif
  53.  
  54. #ifndef _DEBUG
  55. #  define assert(ignore) ((void)0)
  56. #else
  57. #  define __SR(x) __VL(x)
  58. #  define __VL(x) #x
  59. #  define assert(e) ((e) ? (void)0 : Desk_WAssert__wassert("Assertion " #e " failed at line " __SR(__LINE__) " of file " __FILE__))
  60.  
  61. #ifdef __cplusplus
  62. }
  63. #endif
  64.  
  65.  
  66. #endif
  67.  
  68.